<template>
  <div class="Cate">
    <van-search v-model="value" placeholder="点击搜索商品名称" id="anchor"/>
    <div class="Cate_conter">
      <div class="Cate_left">
        <div
          class="left_item"
          :class="currentId == index ? 'Active' : ''"
          v-for="(item,index) in leftList"
          @click="changeType(index)"
        >
          {{ item.name }}
        </div>
      </div>
      <div class="Cate_right" ref="right">
        <Categoods :leftList="leftList" :ismove="ismove"></Categoods>
      </div>
    </div>
  </div>
</template>

<script>
const Categoods = () => import("@/components/Cate/Categoods.vue");
export default {
  name: "FxhDemoCateView",
  components: { Categoods },
  data() {
    return {
      value: undefined, //搜索框输入的值
      leftList: [], //左侧列表,
      currentId: 0, //当前点击id
      ismove:false, //定位
      moveHeight:undefined,//移动距离
    };
  },
  async created() {
    const {
      data: { data },
    } = await this.$request("get", "/fxh/category");
    console.log(data);
    this.leftList = data;
  },
  mounted() {},

  methods: {
    changeType(index) {
      this.currentId = index;
      if(index==0){
        this.ismove=false;
      }else if(index==1){
        this.ismove=true
      }
    //  this.moveHeight=this.currentId*-40
    //  this.$store.commit("setMove",this.moveHeight)
    },
  },
};
</script>

<style lang="scss" scoped>
.Cate {
  background: white;
  width: 375px;
  height: 85vh;
  .van-search{
    width: 375px;
    position: fixed;
    top: 0;
    z-index: 1000 ;
  }
  .Cate_conter {
    margin-top:8.7vh;
    height: 87vh;
    overflow: hidden;
    @include flex;
    background: white;
    width: 375px;
    .Cate_left {
      overflow-y: scroll;
      width: 90px;
      background-color: #f7f7f7;
      height: 87vh;
      @include cloumn;
      justify-content: start;
      .left_item {
        width: 90px;
        height: 50px;
        text-align: center;
        line-height: 50px;
        font-size: 13px;
        color: #424242;
      }
    }
    .Cate_right {
      overflow: hidden;
      width: 285px;
      height: 87vh;
      background: white;
      margin-top: 0;
    }
  }
}
.Active {
  background: white;
}
</style>
